﻿using System;
using System.Text.RegularExpressions;
using WAD.DAL;
using WAD.WEB.AppCode;
namespace WAD.WEB.Client.Page
{
    public partial class TouTiao : WebBase
    {
        protected string html, json_id;
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = Parse.Int("source_id", 0);
            if (id > 0)
            {
                html = DaoUrlSource.GetEntityById(id);
                
                html = html.Replace("href=\"//", "href=\"http://").Replace("src=\"//", "src=\"http://").Replace("body-placeholder\"", "body-placeholder\" style='display:none'");
                html = html.Replace("<head>", "<head><meta name=\"viewport\" content=\"width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;\" />" +
                    "<meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />" +
                    "<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black\" />" +
                    "<meta name=\"format-detection\" content=\"telephone=no\" />");

               // html = html.Replace("onload=\"onPlaceHolderLoaded()\"", "");
                Regex r1 = new Regex("[a-zA-z]+://www.toutiao.com/i[^\\s]*");

                if (r1.IsMatch(html))
                {
                    var url= r1.Match(html).Groups[0].Value;
                    json_id = url.Remove(0, 24).TrimEnd('"');
                    
                }
                    
            }
        }
    }
}